package com.books.mapper;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.books.model.BookInfo;
import com.books.model.PageRequest;
import com.fasterxml.jackson.databind.ser.Serializers;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface bookInfoMapper extends BaseMapper<BookInfo> {
    @Insert("INSERT INTO book_info(book_name,author,count,price,publish,`status`)" +
            "VALUES(#{bookName},#{author},#{count},#{price},#{publish},#{status})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    Integer addBook(BookInfo bookInfo);

    @Select("select *from book_info where `status`!=0 limit #{offset},#{pageSize}")
    List<BookInfo> selectBookByPage(PageRequest pageRequest);

    @Select("select count(1) from book_info where `status`!=0")
Integer count();

@Select("select *from book_info where `status`!=0 and id=#{bookId}")
    BookInfo queryBoookById(Integer bookId);

    void updateBook(BookInfo bookInfo);

    void batchDelete(@Param("ew") LambdaUpdateWrapper<BookInfo> wrapper, @Param("status") Integer code);
}
